this.BX=this.BX||{};this.BX.UI=this.BX.UI||{};(function(e,t,i,s,a){"use strict";var l;function n(e,t){c(e,t);t.add(e)}function r(e,t,i){c(e,t);t.set(e,i)}function c(e,t){if(t.has(e)){throw new TypeError("Cannot initialize the same private elements twice on an object")}}function u(e,t,i){if(!t.has(e)){throw new TypeError("attempted to get private field on non-instance")}return i}var b=new WeakMap;var v=new WeakMap;var o=new WeakMap;var h=new WeakSet;var d=function(e){babelHelpers.inherits(t,e);function t(){var e;var i=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};babelHelpers.classCallCheck(this,t);e=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this));n(babelHelpers.assertThisInitialized(e),h);r(babelHelpers.assertThisInitialized(e),b,{writable:true,value:[]});r(babelHelpers.assertThisInitialized(e),v,{writable:true,value:void 0});r(babelHelpers.assertThisInitialized(e),o,{writable:true,value:false});e.setEventNamespace("ui:sidepanel:menu:collection");e.setItems(i.items);return e}babelHelpers.createClass(t,[{key:"setActiveFirstItem",value:function e(){var t=this.list()[0];if(!t){return}t.setActive(true);t.getCollection().setActiveFirstItem()}},{key:"getActiveItem",value:function e(){return this.list().filter((function(e){return e.isActive()}))[0]}},{key:"syncActive",value:function e(t){if(babelHelpers.classPrivateFieldGet(this,o)){return this}babelHelpers.classPrivateFieldSet(this,o,true);this.list().filter((function(e){return e!==t})).forEach((function(e){e.getCollection().isEmpty()?e.setActive(false):e.getCollection().syncActive(e)}));this.emit("sync:active");babelHelpers.classPrivateFieldSet(this,o,false);return this}},{key:"add",value:function e(t){var i=u(this,h,p).call(this,t);this.emit("change");if(babelHelpers.classPrivateFieldGet(this,v)){this.render()}return i}},{key:"get",value:function e(t){return this.list().filter((function(e){return e.getId()===t}))[0]}},{key:"change",value:function e(t,i){var s=this.list().find((function(e){return e.getId()===t}));if(s){s.change(i);return s}return null}},{key:"remove",value:function e(t){var i=this.list().find((function(e){return e.getId()===t}));if(i){this.emit("change");babelHelpers.classPrivateFieldSet(this,b,this.list().filter((function(e){return e!==i})));i.remove()}}},{key:"setItems",value:function e(){var t=this;var i=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];babelHelpers.classPrivateFieldSet(this,b,i.map((function(e){return u(t,h,p).call(t,e)})));this.emit("change");if(babelHelpers.classPrivateFieldGet(this,v)){this.render()}return this}},{key:"list",value:function e(){return babelHelpers.classPrivateFieldGet(this,b)}},{key:"isEmpty",value:function e(){return this.list().length===0}},{key:"hasActive",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;var i=this.list().some((function(e){return e.isActive()}));if(i){return true}if(!t){return false}return this.list().some((function(e){return e.getCollection().hasActive()}))}},{key:"render",value:function e(){var t=this;if(!babelHelpers.classPrivateFieldGet(this,v)){babelHelpers.classPrivateFieldSet(this,v,a.Tag.render(l||(l=babelHelpers.taggedTemplateLiteral(['<div class="ui-sidepanel-menu-items"></div>']))))}babelHelpers.classPrivateFieldGet(this,v).innerHTML="";babelHelpers.classPrivateFieldGet(this,b).forEach((function(e){return babelHelpers.classPrivateFieldGet(t,v).appendChild(e.render())}));return babelHelpers.classPrivateFieldGet(this,v)}}]);return t}(s.EventEmitter);function p(e){var t=this;if(e.active){e.active=!this.hasActive()}else{e.active=false}var i=new W(e);babelHelpers.classPrivateFieldGet(this,b).push(i);i.subscribe("change:active",(function(){if(i.isActive()&&i.getCollection().isEmpty()){t.syncActive(i)}}));i.subscribe("sync:active",(function(){return t.syncActive(i)}));i.subscribe("click",(function(e){return t.emit("click",e)}));i.subscribe("change",(function(){return setTimeout((function(){return t.render()}),0)}));return i}var f,H,m;function g(e,t){k(e,t);t.add(e)}function P(e,t,i){k(e,t);t.set(e,i)}function k(e,t){if(t.has(e)){throw new TypeError("Cannot initialize the same private elements twice on an object")}}function y(e,t,i){if(!t.has(e)){throw new TypeError("attempted to get private field on non-instance")}return i}var F=new WeakMap;var w=new WeakMap;var T=new WeakMap;var I=new WeakMap;var G=new WeakMap;var C=new WeakMap;var A=new WeakMap;var E=new WeakMap;var M=new WeakSet;var S=new WeakSet;var z=new WeakSet;var W=function(e){babelHelpers.inherits(t,e);function t(e){var i;babelHelpers.classCallCheck(this,t);i=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));g(babelHelpers.assertThisInitialized(i),z);g(babelHelpers.assertThisInitialized(i),S);g(babelHelpers.assertThisInitialized(i),M);P(babelHelpers.assertThisInitialized(i),F,{writable:true,value:void 0});P(babelHelpers.assertThisInitialized(i),w,{writable:true,value:void 0});P(babelHelpers.assertThisInitialized(i),T,{writable:true,value:void 0});P(babelHelpers.assertThisInitialized(i),I,{writable:true,value:void 0});P(babelHelpers.assertThisInitialized(i),G,{writable:true,value:void 0});P(babelHelpers.assertThisInitialized(i),C,{writable:true,value:void 0});P(babelHelpers.assertThisInitialized(i),A,{writable:true,value:void 0});P(babelHelpers.assertThisInitialized(i),E,{writable:true,value:void 0});i.setEventNamespace("ui:sidepanel:menu:item");babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(i),C,new d);i.setLabel(e.label).setActive(e.active).setNotice(e.notice).setId(e.id).setItems(e.items).setClickHandler(e.onclick).setActions(e.actions);babelHelpers.classPrivateFieldGet(babelHelpers.assertThisInitialized(i),C).subscribe("sync:active",(function(){return i.emit("sync:active")}));babelHelpers.classPrivateFieldGet(babelHelpers.assertThisInitialized(i),C).subscribe("click",(function(e){return i.emit("click",e)}));return i}babelHelpers.createClass(t,[{key:"setLabel",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"";if(babelHelpers.classPrivateFieldGet(this,w)===t){return this}babelHelpers.classPrivateFieldSet(this,w,t);y(this,M,L).call(this);return this}},{key:"setId",value:function e(t){if(babelHelpers.classPrivateFieldGet(this,F)===t){return this}babelHelpers.classPrivateFieldSet(this,F,t);y(this,M,L).call(this);return this}},{key:"setActive",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;t=!!t;if(babelHelpers.classPrivateFieldGet(this,T)===t){return this}babelHelpers.classPrivateFieldSet(this,T,t);y(this,M,L).call(this,{active:babelHelpers.classPrivateFieldGet(this,T)},"active");return this}},{key:"setNotice",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;babelHelpers.classPrivateFieldSet(this,I,!!t);y(this,M,L).call(this);return this}},{key:"setClickHandler",value:function e(t){babelHelpers.classPrivateFieldSet(this,G,t);return this}},{key:"setActions",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];babelHelpers.classPrivateFieldSet(this,E,t);return this}},{key:"setItems",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];babelHelpers.classPrivateFieldGet(this,C).setItems(t||[]);y(this,M,L).call(this);return this}},{key:"getCollection",value:function e(){return babelHelpers.classPrivateFieldGet(this,C)}},{key:"getLabel",value:function e(){return babelHelpers.classPrivateFieldGet(this,w)}},{key:"getId",value:function e(){return babelHelpers.classPrivateFieldGet(this,F)}},{key:"getClickHandler",value:function e(){return babelHelpers.classPrivateFieldGet(this,G)}},{key:"isActive",value:function e(){return babelHelpers.classPrivateFieldGet(this,T)}},{key:"hasNotice",value:function e(){return babelHelpers.classPrivateFieldGet(this,I)}},{key:"hasActions",value:function e(){return babelHelpers.classPrivateFieldGet(this,E).length>0}},{key:"change",value:function e(t){if(!a.Type.isUndefined(t.label)){this.setLabel(t.label)}if(!a.Type.isUndefined(t.active)){this.setActive(t.active)}if(!a.Type.isUndefined(t.notice)){this.setNotice(t.notice)}if(!a.Type.isUndefined(t.id)){this.setId(t.id)}if(!a.Type.isUndefined(t.items)){this.setItems(t.items)}if(!a.Type.isUndefined(t.onclick)){this.setClickHandler(t.onclick)}if(!a.Type.isUndefined(t.actions)){this.setActions(t.actions)}}},{key:"remove",value:function e(){a.Dom.remove(babelHelpers.classPrivateFieldGet(this,A));babelHelpers.classPrivateFieldSet(this,A,null)}},{key:"render",value:function e(){var t=babelHelpers.classPrivateFieldGet(this,C).isEmpty();var i=[];if(babelHelpers.classPrivateFieldGet(this,T)){if(t){i.push("ui-sidepanel-menu-active")}else{i.push("ui-sidepanel-menu-expand")}}var s=a.Loc.getMessage("UI_SIDEPANEL_MENU_JS_"+(this.isActive()?"COLLAPSE":"EXPAND"));babelHelpers.classPrivateFieldSet(this,A,a.Tag.render(f||(f=babelHelpers.taggedTemplateLiteral(['\n\t\t\t<li class="ui-sidepanel-menu-item ','">\n\t\t\t\t<a\n\t\t\t\t\tclass="ui-sidepanel-menu-link"\n\t\t\t\t\tonclick="','"\n\t\t\t\t\ttitle="','"\n\t\t\t\t>\n\t\t\t\t\t<div class="ui-sidepanel-menu-link-text">',"</div>\n\t\t\t\t\t","\n\t\t\t\t\t","\n\t\t\t\t\t","\n\t\t\t\t</a>\n\t\t\t</li>\n\t\t"])),i.join(" "),y(this,S,U).bind(this),a.Tag.safe(H||(H=babelHelpers.taggedTemplateLiteral(["",""])),babelHelpers.classPrivateFieldGet(this,w)),a.Tag.safe(m||(m=babelHelpers.taggedTemplateLiteral(["",""])),babelHelpers.classPrivateFieldGet(this,w)),!t?'<div class="ui-sidepanel-toggle-btn">'.concat(s,"</div>"):"",babelHelpers.classPrivateFieldGet(this,I)?'<span class="ui-sidepanel-menu-notice-icon"></span>':"",this.hasActions()?'<span class="ui-sidepanel-menu-action-icon ui-btn ui-btn-link ui-btn-icon-edit"></span>':""));if(this.hasActions()){a.Event.bind(babelHelpers.classPrivateFieldGet(this,A).querySelector(".ui-sidepanel-menu-action-icon"),"click",y(this,z,N).bind(this))}if(!babelHelpers.classPrivateFieldGet(this,C).isEmpty()){a.Dom.append(babelHelpers.classPrivateFieldGet(this,C).render(),babelHelpers.classPrivateFieldGet(this,A))}return babelHelpers.classPrivateFieldGet(this,A)}}]);return t}(s.EventEmitter);function L(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;this.emit("change",e);if(t){this.emit("change:"+t,e)}}function U(e){e.preventDefault();e.stopPropagation();this.setActive(babelHelpers.classPrivateFieldGet(this,C).isEmpty()||!this.isActive());this.emit("click",{item:this});if(a.Type.isFunction(babelHelpers.classPrivateFieldGet(this,G))){babelHelpers.classPrivateFieldGet(this,G).apply(this)}}function N(e){var t=this;e.preventDefault();e.stopPropagation();if(this.actionsMenu){this.actionsMenu.getPopupWindow().close();return}var s=e.currentTarget;a.Dom.addClass(s,"--hover");a.Dom.addClass(s.parentNode,"--hover");this.actionsMenu=new i.Menu({id:"ui-sidepanel-menu-item-actions-".concat(this.getId()),bindElement:s});babelHelpers.classPrivateFieldGet(this,E).forEach((function(e){t.actionsMenu.addMenuItem({text:e.label,onclick:function i(s,a){a.getMenuWindow().close();e.onclick(t)}})}));this.actionsMenu.getPopupWindow().subscribe("onClose",(function(){a.Dom.removeClass(s,"--hover");a.Dom.removeClass(s.parentNode,"--hover");t.actionsMenu.destroy();t.actionsMenu=null}));this.actionsMenu.show()}var X;function B(e,t,i){D(e,t);t.set(e,i)}function D(e,t){if(t.has(e)){throw new TypeError("Cannot initialize the same private elements twice on an object")}}var O=new WeakMap;var j=function(e){babelHelpers.inherits(t,e);function t(){var e;var i=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};babelHelpers.classCallCheck(this,t);e=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,{items:i.items}));B(babelHelpers.assertThisInitialized(e),O,{writable:true,value:void 0});if(!e.hasActive()){e.setActiveFirstItem()}return e}babelHelpers.createClass(t,[{key:"render",value:function e(){var i=babelHelpers.get(babelHelpers.getPrototypeOf(t.prototype),"render",this).call(this);if(!babelHelpers.classPrivateFieldGet(this,O)){babelHelpers.classPrivateFieldSet(this,O,a.Tag.render(X||(X=babelHelpers.taggedTemplateLiteral(['<ul class="ui-sidepanel-menu"></ul>']))));babelHelpers.classPrivateFieldGet(this,O).appendChild(i)}return babelHelpers.classPrivateFieldGet(this,O)}},{key:"renderTo",value:function e(t){var i=this.render();t.appendChild(i);return i}}]);return t}(d);e.Item=W;e.Menu=j})(this.BX.UI.SidePanel=this.BX.UI.SidePanel||{},BX,BX.Main,BX.Event,BX);
//# sourceMappingURL=bundle.map.js